package me.zingon.doc.constant;

import java.util.HashMap;
import java.util.Map;

public enum LockStatusEnum {
    UNKNOW(-1,"离线"),LOCK_DOWN(0,"底部状态"),LOCK_UP(1,"顶部状态"),LOCK_MOVING(2,"运动状态");

    Integer code;
    String name;

    LockStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static LockStatusEnum getByCode(Integer code){
        for(LockStatusEnum lse:LockStatusEnum.values()){
            if(lse.getCode().equals(code)){
                return lse;
            }
        }
        return null;
    }
    
    public static String getNameByCode(Integer code){
        for(LockStatusEnum lse:LockStatusEnum.values()){
            if(lse.getCode().equals(code)){
                return lse.getName();
            }
        }
        return "";
    }

    public static Map<String,String> toMap(){
        Map<String,String> result=new HashMap<String, String>(LockStatusEnum.values().length);
        for(LockStatusEnum lse:LockStatusEnum.values()){
           result.put(lse.getCode().toString(),lse.getName());
        }
        return result;
    }
}
